#ifndef HTTP_MANAGER_H_
#define HTTP_MANAGER_H_
#include <curl/curl.h>


#define TIMETYPE double
#define TIMEOPT CURLINFO_TOTAL_TIME
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 1
#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES 6000

#define CURL_DOWNLOADING 1
#define CURL_CANCEL 0


typedef struct _httpcontext
{
    char url[URL_MAX_LEN];
    char filename[FILENAME_LEN];

    FILE *stream;
    CURL *curl;
    //curl 返回的错误
    CURLcode curl_code;
    //http返回的错误
    int http_code;
    //是否只请求头部
    int headonly;

    TIMETYPE lastruntime; /* type depends on version, see above */
    curl_off_t lastdlsize; //上一次下载大小

    curl_off_t totalsize; //文件大小
    void *row;

    float progress;
    char transfer_rate_str[16];
    char estimate_time_str[16];

} HttpContext;

//停止下载
void CancelDownloadFile(void);
void *RequestUrl(void *vargp);

#endif